package com.zjitc.utils;

import java.util.Random;
import java.util.UUID;

public class UUIDUtils {
	/**
	 * 随机生成id
	 * @return
	 */
	public static String getId(){
		return UUID.randomUUID().toString().replace("-", "").toUpperCase();
	}
	
	/**
	 * 生成随机码
	 * @return
	 */
	public static String getCode(){
		// 验证码中所使用到的字符
		char[] codeChar = "0123456789".toCharArray();
		// 存放生成的验证码
		String msg = "";
		Random random = new Random();
		for(int i = 0; i < 3; i++) { // 循环将每个验证码字符绘制到图片上
			int index = random.nextInt(codeChar.length);
			msg += codeChar[index];
		}
		return msg;
	}
	
	public static void main(String[] args) {
		System.out.println(getId());
	}
}
